<template>
	<div class="ll-page">
		<div class="ll-page-apply">
			<div v-if="applyCountVideoIsShow" class="ll-page-apply-box">
				<template v-for="(item, key, index) in applyCountVideo" :key="index">
					<div
						class="ll-page-apply-box-item"
						:class="applyCountIndex === index ? 'isActive' : ''"
						@click="applyCountChange(item, index)"
					>
						<p>{{ item.label }}</p>
						<p>{{ item.value }}</p>
					</div>
				</template>
			</div>
			<div v-else class="ll-page-apply-box">
				<template v-for="(item, key, index) in applyCount" :key="index">
					<div
						class="ll-page-apply-box-item"
						:class="applyCountIndex === index ? 'isActive' : ''"
						@click="applyCountChange(item, index)"
					>
						<p>{{ item.label }}</p>
						<p>{{ item.value }}</p>
					</div>
				</template>
			</div>
		</div>
		<!-- S 查询 -->
		<div class="ll-page-query flex">
			<n-form
				inline
				:model="formValue"
				label-placement="left"
				:show-feedback="false"
				class="flex-1 flex-wrap"
			>
				<n-form-item label="主播信息：" path="value">
					<n-input
						v-model:value="formValue.agentInfo"
						placeholder="输入主播姓名/电话搜索"
						:autosize="true"
						class="w-220px"
						@keyup.enter="updateFormValue"
					/>
				</n-form-item>
				<n-form-item label="状态：" path="value">
					<n-select
						v-model:value="formValue.status"
						:options="options"
						class="w-193px"
						@update:value="changeStatus"
					/>
				</n-form-item>
				<n-form-item label="提交时间：" path="value">
					<n-date-picker v-model:value="timeData" type="daterange" />
				</n-form-item>
				<n-form-item label="订单/产品：" path="value">
					<n-input
						v-model:value="formValue.keyWord"
						placeholder="输入订单编号/产品ID/产品名称搜索"
						:autosize="true"
						class="w-291px"
						@keyup.enter="updateFormValue"
					/>
				</n-form-item>
				<n-form-item label="站点：" path="value">
					<n-select
						v-model:value="formValue.locationId"
						:options="locationOptions"
						class="w-193px"
						filterable
						:clearable="locationClearable ? true : false"
						@update:value="updateLocation"
					/>
				</n-form-item>
				<n-form-item v-if="isSelectionShow" label="佣金模式：" path="value">
					<n-select
						v-model:value="formValue.commissionType"
						class="w-220px"
						:options="[
							{
								label: '全部',
								value: 0
							},
							{
								label: '一口价',
								value: 1
							},
							{
								label: '一口价+CPS',
								value: 2
							},
							{
								label: 'CPS',
								value: 3
							}
						]"
						@update:value="getList"
					/>
				</n-form-item>
			</n-form>
			<n-space>
				<n-button type="primary" @click="handelQuery">查询</n-button>
				<n-button color="rgba(0, 0, 0, 0.1)" text-color="#333333" @click="handelReset">
					重置
				</n-button>
			</n-space>
		</div>
		<!-- E 查询 -->
		<div
			v-if="
				[
					'/apply-review/findListReviewCheck',
					'/apply-review/findListReviewCheckAdmin',
					'/apply-review/findListWithPerson',
					'/apply-review/findListWithPersonAdmin',
					'/apply-review/findListWithVideoPerson',
					'/apply-review/findListWithVideoPersonAdmin'
				].includes(route.path)
			"
			class="ll-page-table-audit"
		>
			<n-space>
				<n-button
					type="primary"
					:disabled="!checkedRowKeysRef.length"
					@click="auditShowModel = true"
				>
					批量通过
				</n-button>
				<n-button
					type="error"
					:disabled="!checkedRowKeysRef.length"
					@click="showApproveMessage = true"
				>
					批量驳回
				</n-button>
			</n-space>
		</div>
		<!-- S 表格 -->
		<div class="ll-page-table">
			<n-data-table
				v-model:checked-row-keys="checkedRowKeysRef"
				:columns="columns"
				:data="tabelData"
				:pagination="pagination"
				:remote="true"
				:loading="tableLoading"
				size="small"
				flex-height
				:row-key="rowKey"
				:style="{ height: '100%' }"
			/>
		</div>
		<!-- 批量通过 -->
		<n-modal
			v-model:show="auditShowModel"
			title="批量通过"
			preset="dialog"
			:show-icon="false"
			:mask-closable="false"
			style="width: 423px"
			@close="handleCloseApproveMessage"
		>
			<p style="color: #1d2129">
				确定批量审批通过当前选择的
				<span style="color: #1d6fe9">{{ checkedRowKeysRef.length }}</span>
				条申请数据？
			</p>
			<template #action>
				<n-button size="small" @click="handleCloseApproveMessage">关闭</n-button>
				<n-button type="primary" size="small" @click="batchAuditConfirm(1)">确认</n-button>
			</template>
		</n-modal>
		<!-- 批量驳回 -->
		<n-modal
			v-model:show="showApproveMessage"
			title="批量驳回"
			preset="dialog"
			:show-icon="false"
			:mask-closable="false"
			style="width: 423px"
			@close="handleCloseApproveMessage"
		>
			<p>
				<span style="color: #f55f4e">*</span>
				<span style="font-weight: 600">驳回理由</span>
			</p>
			<n-input
				v-model:value="backMessage"
				type="textarea"
				placeholder="请输入驳回原因"
				show-count
				maxlength="100"
				minlength="1"
			/>
			<template #action>
				<n-button size="small" @click="handleCloseApproveMessage">关闭</n-button>
				<n-button
					:disabled="!backMessage"
					type="primary"
					size="small"
					@click="batchAuditConfirm(2)"
				>
					确认
				</n-button>
			</template>
		</n-modal>
		<!-- E 表格 -->

		<!-- 探店申请审核 -->
		<ApplyAudit v-model:modal="applyAuditModal" :apply-id="applyId" @commit="getList" />
		<!-- 详情 -->
		<AuditDetails v-model:modal="auditDetailsModal" :apply-id="applyId" />
		<!-- 驳回原因 -->
		<Rejected v-model:modal="rejectedModal" :apply-id="applyId" @commit="getList" />
		<!-- 探店完成审核 -->
		<AuditConfirm v-model:modal="auditConfirmModal" :apply-id="applyId" @commit="getList" />
	</div>
</template>
<script setup>
import { h, ref, reactive, watch, nextTick } from 'vue';
import { NButton, useMessage } from 'naive-ui';
import { useRoute, useRouter } from 'vue-router';
import ApplyAudit from './components/ApplyAudit.vue';
import AuditDetails from './components/AuditDetails.vue';
import Rejected from './components/Rejected.vue';
import AuditConfirm from './components/AuditConfirm.vue';

import dayjs from 'dayjs';
// 导入API接口
import {
	findListWithAdmin,
	findListWithCC,
	findListWithPerson,
	findListWithPosition,
	findListWithVideoPerson,
	findListStatusSelect,
	findListReviewCheck,
	managerApplyCount,
	auditReviewCheckList,
	auditWithPersonList,
	auditWithVideoPersonList
} from '@/api/applyReview';

// 导入API接口
import { locationList, locationListFz } from '@/api/product';
const message = useMessage();

const router = useRouter();
const route = useRoute();
// 状态
const options = ref([]);
// 站点
const locationOptions = ref([]);
const locationClearable = ref(false);

// 获取站点数据
const getLocationList = async () => {
	const setForm = {
		city: ''
	};
	locationOptions.value = [];
	let res = null;
	formValue.locationId = null;
	if (
		router.currentRoute.value.fullPath === '/apply-review/findListWithCC' ||
		router.currentRoute.value.fullPath === '/apply-review/findListWithAdmin' ||
		router.currentRoute.value.fullPath === '/apply-review/findListWithPersonAdmin' ||
		router.currentRoute.value.fullPath === '/apply-review/findListWithPositionAdmin' ||
		router.currentRoute.value.fullPath === '/apply-review/findListWithVideoPersonAdmin' ||
		router.currentRoute.value.fullPath === '/apply-review/findListReviewCheckAdmin'
	) {
		res = await locationList(setForm);
		locationClearable.value = true;
	} else {
		res = await locationListFz(setForm);
		locationClearable.value = false;
	}
	if (res && res.code === 0) {
		locationOptions.value = res.data.map((item) => {
			item.label = item.city;
			item.value = item.id;
			return item;
		});
	}
	if (
		router.currentRoute.value.fullPath !== '/apply-review/findListWithCC' &&
		router.currentRoute.value.fullPath !== '/apply-review/findListWithAdmin'
	) {
		locationOptions.value.length && (formValue.locationId = locationOptions.value[0].id);
	}
};

// 切换站点
const updateLocation = (locationId) => {
	formValue.locationId = locationId;
	formValue.pageIndex = 1;
	formValue.pageSize = 10;
	// 重置分页
	pagination.page = 1;
	getList();
};

const getFindListStatusSelect = async () => {
	let params = {
		videoAuditFlag:
			router.currentRoute.value.fullPath === '/apply-review/findListWithVideoPerson' ? 1 : 0
	};
	const res = await findListStatusSelect(params);
	if (res.code === 200) {
		options.value = res.data.map((item) => {
			item.label = item.name;
			return item;
		});
		formValue.status = options.value[0].value;
	}
};

// 确认审核按钮逻辑
const applyCountVideoIsShow = ref(false);
const applyCount = reactive({
	all: { value: ' ', label: '全部', type: 0 },
	firstReview: { value: null, label: '初审', type: 101 },
	secondReview: { value: null, label: '复审', type: 102 },
	lastReview: { value: null, label: '终审', type: 103 },
	inTd: { value: null, label: '探店中', type: 11 },
	affirmInfo: { value: null, label: '待确认', type: 2 },
	refused: { value: null, label: '已驳回', type: 12 },
	success: { value: null, label: '已完成', type: 22 }
});

const applyCountVideo = reactive({
	all: { value: null, label: '全部', type: 3 },
	affirmInfo: { value: null, label: '待确认', type: 21 },
	success: { value: null, label: '已完成', type: 22 },
	refused: { value: null, label: '已驳回', type: 23 }
});

const applyCountChange = (item, index) => {
	applyCountIndex.value = index;
	formValue.status = item.type;
	updateFormValue();
};
const applyCountIndex = ref(0);
const getManagerApplyCount = async () => {
	if (router.currentRoute.value.fullPath === '/apply-review/findListWithVideoPerson') {
		applyCountVideoIsShow.value = true;
	} else {
		applyCountVideoIsShow.value = false;
	}
	applyCountIndex.value = 0;
	formValue.status = null;
	let res = await managerApplyCount();
	if (res.code === 200) {
		if (applyCountVideoIsShow.value) {
			Object.keys(applyCountVideo).forEach((key) => {
				applyCountVideo[key].value = res.data[key];
			});
		} else {
			Object.keys(applyCount).forEach((key) => {
				applyCount[key].value = res.data[key];
			});
		}
	}
};
const showApproveMessage = ref(false);
const auditShowModel = ref(false);

const backMessage = ref('');
const handleCloseApproveMessage = () => {
	showApproveMessage.value = false;
	auditShowModel.value = false;
	backMessage.value = '';
	checkedRowKeysRef.value = [];
};

const batchAuditConfirm = async (type) => {
	let parmas = {
		seekIdList: checkedRowKeysRef.value, //id list
		result: type, //1 通过 2驳回
		message: backMessage.value // 驳回原因
	};
	let res = null;
	// 批量审核
	if (type === 2 && !backMessage.value) {
		message.error('请输入驳回信息');
		return;
	}
	if (
		['/apply-review/findListReviewCheck', '/apply-review/findListReviewCheckAdmin'].includes(
			route.path
		)
	) {
		// 复审
		res = await auditReviewCheckList(parmas);
	} else if (
		['/apply-review/findListWithPerson', '/apply-review/findListWithPersonAdmin'].includes(
			route.path
		)
	) {
		// 终审
		res = await auditWithPersonList(parmas);
	} else if (
		[
			'/apply-review/findListWithVideoPerson',
			'/apply-review/findListWithVideoPersonAdmin'
		].includes(route.path)
	) {
		// 视频审核
		res = await auditWithVideoPersonList(parmas);
	}

	if (res && res.code === 200) {
		message.success(`操作成功${res.data.success}条，失败${res.data.fail}条`);
		handleCloseApproveMessage();
		await getList();
	} else {
		message.error(res.message);
	}
};
// 多选使用
const checkedRowKeysRef = ref([]);
const rowKey = (row) => {
	// 绑定值
	return row.id;
};

const handleCheck = (rowKeys) => {
	// 选中
	checkedRowKeysRef.value = rowKeys;
};
const isSelectionShow = () => {
	// 多选框是否显示
	let routerSelection = [
		'/apply-review/findListReviewCheck',
		'/apply-review/findListReviewCheckAdmin',
		'/apply-review/findListWithPerson',
		'/apply-review/findListWithPersonAdmin',
		'/apply-review/findListWithVideoPerson',
		'/apply-review/findListWithVideoPersonAdmin'
	];
	return routerSelection.includes(route.path);
};
// 表格
const columns = ref([]);
const tabelData = ref([]);
const tableLoading = ref(false);

// 查询条件
const formValue = reactive({
	keyWord: null,
	agentInfo: null,
	endDate: null,
	startDate: null,
	status: null,
	locationId: null,
	commissionType: 0,
	pageIndex: 1,
	pageSize: 10
});
// 提交时间
const timeData = ref(null);
// 监听提交时间
watch(timeData, (count) => {
	if (count) {
		formValue.startDate = dayjs(count[0])
			.set('hour', 0)
			.set('minute', 0)
			.set('second', 0)
			.format('YYYY-MM-DD HH:mm:ss');
		formValue.endDate = dayjs(count[1])
			.set('hour', 23)
			.set('minute', 59)
			.set('second', 59)
			.format('YYYY-MM-DD HH:mm:ss');
	} else {
		formValue.startDate = null;
		formValue.endDate = null;
	}
	updateFormValue();
});
const changeStatus = (value) => {
	let hasApplyCountIndex = false; //是否包含着相同值
	if (applyCountVideoIsShow.value) {
		Object.keys(applyCountVideo).forEach((key, index) => {
			if (applyCountVideo[key].type == value) {
				applyCountIndex.value = index;
				hasApplyCountIndex = true;
			}
		});
	} else {
		Object.keys(applyCount).forEach((key, index) => {
			if (applyCount[key].type == value) {
				applyCountIndex.value = index;
				hasApplyCountIndex = true;
			}
		});
	}
	if (!hasApplyCountIndex) {
		applyCountIndex.value = null;
	}
	updateFormValue();
};
// 分页
const pagination = reactive({
	page: 1,
	pageSize: formValue.pageSize,
	pageSizes: [10, 20, 30, 40],
	showSizePicker: true,
	itemCount: 0,
	prefix({ itemCount }) {
		return `共${itemCount}条`;
	},
	onChange: (page) => {
		pagination.page = page;
		formValue.pageIndex = page;
		getList();
	},
	onPageSizeChange: (pageSize) => {
		pagination.pageSize = pageSize;
		formValue.pageSize = pageSize;
		formValue.pageIndex = 1;
		pagination.page = 1;
		// getList();
		getList();
	}
});

// 获取跳转数据
const getQuery = () => {
	console.log(route.query);
	if (route.query.agentInfo) {
		formValue.agentInfo = route.query.agentInfo;
	} else if (route.query.keyWord) {
		formValue.keyWord = route.query.keyWord;
	}
};
// 获取列表
const getList = async () => {
	if (!locationOptions.value.length) {
		tabelData.value = [];
		formValue.pageIndex = 1;
		formValue.pageSize = 10;
		pagination.itemCount = 0;
		tableLoading.value = false;
		return;
	}
	const fullPath = router.currentRoute.value.fullPath;
	let res = null;
	tableLoading.value = true;
	// 	router.currentRoute.value.fullPath === '/apply-review/findListWithPersonAdmin'
	if (fullPath === '/apply-review/findListWithAdmin') {
		getQuery();
		res = await findListWithAdmin(formValue);
	} else if (fullPath === '/apply-review/findListWithCC') {
		res = await findListWithCC(formValue);
	} else if (
		fullPath === '/apply-review/findListWithPerson' ||
		fullPath === '/apply-review/findListWithPersonAdmin'
	) {
		res = await findListWithPerson(formValue);
	} else if (
		fullPath === '/apply-review/findListWithPosition' ||
		fullPath === '/apply-review/findListWithPositionAdmin'
	) {
		res = await findListWithPosition(formValue);
	} else if (
		fullPath === '/apply-review/findListWithVideoPerson' ||
		fullPath === '/apply-review/findListWithVideoPersonAdmin'
	) {
		res = await findListWithVideoPerson(formValue);
	} else if (
		fullPath === '/apply-review/findListReviewCheck' ||
		fullPath === '/apply-review/findListReviewCheckAdmin'
	) {
		res = await findListReviewCheck(formValue);
	}
	tableLoading.value = false;
	if (res && res.code === 200) {
		tabelData.value = res.data.data;
		console.log(res.data.data);
		pagination.itemCount = res.data.rowCount;
	}
};
// 操作查询
const handelQuery = () => {
	getList();
};
// 重置
const handelReset = () => {
	formValue.keyWord = null;
	formValue.agentInfo = null;
	formValue.endDate = null;
	formValue.startDate = null;
	formValue.commissionType = 0;
	if (locationClearable.value) {
		formValue.locationId = null;
	}
	formValue.status = options.value[0].value;
	formValue.pageIndex = 1;
	formValue.pageSize = 10;
	timeData.value = null;
	getList();
	// getList();
};

// 数据更新
const updateFormValue = () => {
	formValue.pageIndex = 1;
	formValue.pageSize = 10;
	getList();
};

// 初始化数据
const initData = async () => {
	columns.value = [
		isSelectionShow() && {
			type: 'selection',
			disabled(row) {
				const isDisabled = false;
				if (
					router.currentRoute.value.fullPath === '/apply-review/findListReviewCheck' ||
					router.currentRoute.value.fullPath === '/apply-review/findListReviewCheckAdmin'
				) {
					if (row.auditType === 7 && row.probeStatus === 10) {
						return false;
					} else {
						return true;
					}
				} else if (
					router.currentRoute.value.fullPath === '/apply-review/findListWithPerson' ||
					router.currentRoute.value.fullPath === '/apply-review/findListWithPersonAdmin'
				) {
					if (row.auditType === 2 && row.probeStatus === 10 && row.finalPriceStatus !== 2) {
						return false;
					} else {
						return true;
					}
				} else if (
					router.currentRoute.value.fullPath === '/apply-review/findListWithVideoPerson' ||
					router.currentRoute.value.fullPath === '/apply-review/findListWithVideoPersonAdmin'
				) {
					if (row.auditType === 4 && row.probeStatus === 21) {
						return false;
					} else {
						return true;
					}
				}
			}
		},
		{
			title: '产品信息',
			key: 'name',
			render(row) {
				return [
					h('div', {}, `站点：${row.locationName ? row.locationName : '暂无'}`),
					h('div', {}, `ID：${row.productId ? row.productId : '暂无'}`),
					h('div', {}, `名称：${row.productName ? row.productName : '暂无'}`)
				];
			}
		},
		{
			title: '个人信息',
			key: 'name',
			render(row) {
				return [
					h('div', {}, `${row.name ? row.name : '姓名暂无'}`),
					h('div', {}, `${row.mobile ? row.mobile : '手机号暂无'}`)
				];
			}
		},
		{
			title: '探店模式',
			key: 'seekTypeVal'
		},
		{
			title: '金额',
			key: 'money'
		},
		{
			title: '渠道信息',
			key: 'name',
			render(row) {
				return [
					h('div', {}, `昵称：${row.nickname || '暂无'}`),
					h('div', {}, `账户：${row.channelAccount ? row.channelAccount : '暂无'}`),
					h('div', {}, `粉丝：${row.channelFens ? row.channelFens : '暂无'}`),
					h('div', {}, `带货等级：${row.cargoLevel ? `LV${row.cargoLevel}` : '暂无'}`),

					h('div', {}, `带货分：${row.cargoPoints ? row.cargoPoints : '暂无'}`)
				];
			}
		},
		{
			title: '状态',
			key: 'statusChinese',
			width: 180,
			render(row) {
				return [h('div', {}, `${row.statusChinese}`)];
			}
		},
		{
			title: '操作',
			key: 'actions',
			width: 230,
			render(row) {
				const { auditType, probeStatus } = row;
				const fullPath = router.currentRoute.value.fullPath;

				// 确认审核按钮逻辑
				const confirmAuditRouter = [
					'/apply-review/findListWithVideoPerson',
					'/apply-review/findListWithVideoPersonAdmin'
				];
				const isConfirmAudit =
					confirmAuditRouter.includes(fullPath) && auditType === 4 && probeStatus === 21;

				const isCancel = probeStatus !== 30;

				return [
					h(
						NButton,
						{
							size: 'small',
							text: true,
							type: 'primary',
							style: {
								marginRight: '8px'
							},
							onClick: () => handleAuditDetails(row)
						},
						{ default: () => '详情' }
					),

					isCancel && [
						h(
							NButton,
							{
								size: 'small',
								text: true,
								type: 'primary',
								style:
									router.currentRoute.value.fullPath === '/apply-review/findListWithAdmin' ||
									router.currentRoute.value.fullPath === '/apply-review/findListWithCC' ||
									router.currentRoute.value.fullPath === '/apply-review/findListWithVideoPerson' ||
									(router.currentRoute.value.fullPath ===
										'/apply-review/findListReviewCheckAdmin' &&
										row.finalPriceStatus === 2)
										? {
												marginRight: '8px',
												fontSize: '14px',
												display: 'none'
										  }
										: ((router.currentRoute.value.fullPath ===
												'/apply-review/findListWithPosition' ||
												router.currentRoute.value.fullPath ===
													'/apply-review/findListWithPositionAdmin') &&
												row.auditType === 1 &&
												row.probeStatus === 10 &&
												row.finalPriceStatus !== 2) ||
										  ((router.currentRoute.value.fullPath ===
												'/apply-review/findListReviewCheck' ||
												router.currentRoute.value.fullPath ===
													'/apply-review/findListReviewCheckAdmin') &&
												row.auditType === 7 &&
												row.probeStatus === 10) ||
										  ((router.currentRoute.value.fullPath === '/apply-review/findListWithPerson' ||
												router.currentRoute.value.fullPath ===
													'/apply-review/findListWithPersonAdmin') &&
												row.auditType === 2 &&
												row.probeStatus === 10 &&
												row.finalPriceStatus !== 2)
										? {
												marginRight: '8px',
												fontSize: '14px'
										  }
										: {
												marginRight: '8px',
												fontSize: '14px',
												display: 'none'
										  },
								onClick: () => handleApplyAudit(row)
							},
							{ default: () => '审核' }
						),

						h(
							NButton,
							{
								size: 'small',
								text: true,
								type: 'error',
								style:
									(router.currentRoute.value.fullPath === '/apply-review/findListWithPerson' ||
										router.currentRoute.value.fullPath ===
											'/apply-review/findListWithPersonAdmin') &&
									row.probeStatus !== 22 &&
									row.probeStatus !== 12 &&
									row.probeStatus !== 21
										? { marginRight: '8px' }
										: (router.currentRoute.value.fullPath ===
												'/apply-review/findListWithPosition' ||
												router.currentRoute.value.fullPath ===
													'/apply-review/findListWithPositionAdmin') &&
										  row.probeStatus !== 22 &&
										  row.probeStatus !== 12 &&
										  row.auditType !== 2 &&
										  row.probeStatus !== 21
										? { marginRight: '8px' }
										: (router.currentRoute.value.fullPath === '/apply-review/findListReviewCheck' ||
												router.currentRoute.value.fullPath ===
													'/apply-review/findListReviewCheckAdmin') &&
										  row.probeStatus !== 22 &&
										  row.probeStatus !== 12 &&
										  row.auditType !== 2 &&
										  row.probeStatus !== 21
										? { marginRight: '8px' }
										: {
												display: 'none'
										  },
								onClick: () => handleRejecte(row)
							},
							{ default: () => '驳回' }
						),

						isConfirmAudit &&
							h(
								NButton,
								{
									size: 'small',
									text: true,
									type: 'primary',
									onClick: () => handleAuditConfirm(row)
								},
								{ default: () => '确认审核' }
							)
					]
				]
					.flat()
					.filter(Boolean);
			}
		}
	].filter(Boolean);
	await getManagerApplyCount();
	await getFindListStatusSelect();
	await getLocationList();
	await getList();
};

nextTick(() => {
	initData();
});
// 初始化数据
const resetData = () => {
	formValue.keyWord = null;
	formValue.agentInfo = null;
	formValue.endDate = null;
	formValue.startDate = null;
	formValue.pageIndex = 1;
	formValue.pageSize = 10;
	formValue.commissionType = 0;

	timeData.value = null;
	checkedRowKeysRef.value = [];

	// 重置分页
	pagination.page = 1;

	// 弹框
	applyAuditModal.value = false;
	auditDetailsModal.value = false;
	rejectedModal.value = false;
	auditConfirmModal.value = false;
};

// 监听路由变化
watch(
	() => route.path,
	() => {
		resetData();
		initData();
		isSelectionShow();
	}
);

const applyId = ref(null);
// 探店申请审核
const applyAuditModal = ref(false);
const handleApplyAudit = (res) => {
	applyAuditModal.value = true;
	applyId.value = res.id;
};

// 详情
const auditDetailsModal = ref(false);
const handleAuditDetails = (res) => {
	auditDetailsModal.value = true;
	applyId.value = res.id;
};

// 驳回原因
const rejectedModal = ref(false);
const handleRejecte = (res) => {
	rejectedModal.value = true;
	applyId.value = res.id;
};

// 探店完成审核
const auditConfirmModal = ref(false);
const handleAuditConfirm = (res) => {
	auditConfirmModal.value = true;
	applyId.value = res.id;
};
</script>

<style lang="less" scoped>
.ll-page {
	height: 100%;
	flex-direction: column;
	display: flex;
	&-apply {
		margin: 10px;
		background: linear-gradient(180deg, #f3f6ff 0%, #fcfdff 100%);
		&-box {
			display: flex;
			&-item {
				cursor: pointer;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				border-top: 4px solid transparent;
				width: 160px;
				height: 80px;
				font-size: 16px;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #333333;
				&.isActive {
					border-top: 4px solid #1d6fe9;
					background: linear-gradient(180deg, #dee6ff 0%, rgba(225, 232, 255, 0) 100%);
					font-size: 16px;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #1d6fe9;
				}
			}
		}
	}

	&-query {
		background: @bg;
		padding: @padding-10 @padding-10 0 @padding-10;
		margin-right: 10px;
		margin-left: 10px;
		margin-top: 10px;
		border-radius: 3px;
		border: 1px solid #f0f0f0;
	}
	.ll-page-table-audit {
		padding: 10px;
		display: flex;
		justify-content: flex-end;
		line-height: 50px;
	}
	&-table {
		padding: 10px;
		overflow: hidden;
		flex: 1 1 0%;
	}
}
.n-form-item {
	margin-bottom: @margin-10;
}
</style>
